package com.itelite.common.util;

/**
 * @author 沈洋 邮箱:1845973183@qq.com
 * @create 2021/8/16-9:55
 **/
public class RandomUtils {
    //获取m~n范围内的整数
    public static int getRandom(int m,int n){
        return (int)(Math.random()*(n-m))+m;
    }

    //获取位数为n的随机数
    public static int getRandom(int length){
        int m=getNumber(length);
        int n=m*10-1;
        return (int)(Math.random()*(n-m))+m;
    }

    public static int getNumber(int n){
        if(n<1){
            n=1;
        }
        if(n==1){
            return 1;
        }else{
            n=n-1;
            return 10*getNumber(n);
        }
    }
}